<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      .head {
        color: red;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <list-com>
        <template v-slot:head>
          <div class="head">
            头部
          </div>
        </template>
        <template #foot>
          <div>
            脚步
          </div>
        </template>
        <!-- 默认插槽 -->
        <!-- <template #default>
          <div>
            默认内容
          </div>
        </template> -->
        <template v-slot:default="slotProps">
          <div>{{slotProps.user.lastName}}</div>
        </template>
      </list-com>
    </div>
    <template id="list">
      <div>
        <h1>我是列表组件</h1>
        <slot name="head"></slot>
        <slot name="foot"></slot>
        <!-- <slot></slot> -->
        <!-- 作用域插槽  插槽与父组件传参 -->
        <slot :user="user">
          {{ user.lastName }}
        </slot>
      </div>
    </template>
    <script src="vue.js"></script>
    <script>
      var vm = new Vue({
        el: '#app',
        methods: {},
        components: {
          listCom: {
            template: '#list',
            data() {
              return {
                user: {
                  lastName: '王'
                }
              }
            }
          }
        }
      })
    </script>
  </body>
</html>
